package com.cayte.location;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

import com.cayte.location.CayteLocationCallback.OnGetLocation;

public class MainActivity extends Activity {

	private TextView text;
	private CayteLocationCallback lbscb;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		text = (TextView) findViewById(R.id.text);

		lbscb = new CayteLocationCallback(this);
		lbscb.setMinTime(5000);
		lbscb.startService(new OnGetLocation() {

			@Override
			public void onGet(int state, CayteLocation loc) {
				// TODO Auto-generated method stub
				switch (state) {
				case CayteLocationState.SUCCESS:
					text.setText(loc.toString());
					break;
				default:
					text.setText(state + "");
					break;
				}
			}
		});

	}

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		if (lbscb != null)
			lbscb.stopService();
	}
}
